package chris.config;

import org.springframework.amqp.core.Declarable;
import org.springframework.amqp.core.ExchangeBuilder;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;
import java.util.List;

/**
 * DelayConfig
 *
 * @author nanxin.chen
 * @since 2017/7/5
 */
@Configuration
public class DelayConfig {

    public static final String DELAY_EXCHANGE_NAME = "delay-exchange";
    public static final String DELAY_QUEUE_NAME    = "delay-queue";

    @Bean
    public List<Declarable> delay() {
        return Arrays.asList(
                ExchangeBuilder.directExchange(DELAY_EXCHANGE_NAME).delayed().build(),
                QueueBuilder.durable(DELAY_QUEUE_NAME).build()
        );
    }
}
